package view.panel.play
{
	import control.panel.IPanelControl;
	
	import flash.text.TextField;
	import flash.utils.Dictionary;
	
	import model.play.RecordCardData;
	
	import utils.TextTool;
	
	import view.panel.AbsPanel;
	
	public class CardRecordPanel extends AbsPanel
	{
		private var cards:Dictionary;
		private var hint:TextField;
		
		public function CardRecordPanel(panelControl:IPanelControl)
		{
			super(panelControl);
			resetBg(450,80,.5);
			this.defaultX = 171;
			this.defaultY = 355;
			
			initTitle("text_title_record");
			initCloseBut();
			resetCloseBut();
			dropShadow();
			initTweenPanelOpen();
		
			initRecordCards();
			initHint();
		}
		
		private function initHint():void
		{
			hint = TextTool.getTextFieldXY(140,10,200,20,12,0xFFFFFF,"本局已出现的牌数统计如下:");
			addChild(hint);
		}
		
		private function initRecordCards():void
		{
			cards = new Dictionary();
			var recordCard:RecordCard;
			for (var i:int=3;i<17;i++)
			{	
				recordCard = new RecordCard();
				recordCard.updateTitle(i);
				recordCard.updateCount("0");
				recordCard.x = 17 + 30 * (i - 3);
				recordCard.y = 32;
				addChild(recordCard);
				cards[i] = recordCard;
			}
		}
		
		public function update(datas:Array):void
		{
			var recordCardData:RecordCardData;
			var recordCard:RecordCard;
			
			for each (recordCardData in datas)
			{
				cards[recordCardData.value].updateCount(recordCardData.count);
			}
		}
		
		public function clear():void
		{
			for each (var recordCard:RecordCard in cards)
			{
				recordCard.updateCount("0");
			}
		}
	}
}